<!-- 首件检查历史记录 -->

<script setup>
import { ref, inject, reactive } from 'vue'
import { ElMessageBox } from 'element-plus'
//引入axios
const axios = inject('axios')


//数据
const testdata = reactive({
  "firstCheckRecords": []
})



// [
//   {
//     "id": 1,
//     "test1": 'SFA060123',
//     "test2": 'YK/191875',
//     "test3": 'TMSP1612F-CN006.0001.5',
//     "test4": 'A50069',
//     "test5": '2019-04-03 00:00:00',
//     "test6": '2019-04-01 00:00:00',
//     "test7": '10',
//     "test8": '1',
//     "test9": '通过',
//     "test10": '2019-04-01 15:42:12',
//     "test11": '龚秀明',
//   }
// ]

//发送请求时的附带数据
const Data = reactive({
  "conditions": { "orderNoOrProductionNo": "", "startDate": "", "endDate": "" }
})
//获取所有数据
function selectData() {
  axios({
    method: 'post',
    url: '/api/firstCheckRecords/selectAll',
    // data: Data
  }).then((response) => {
    if (response.data.success) {
      if (response.data.map.firstCheckRecords != null) {
        testdata.firstCheckRecords = response.data.map.firstCheckRecords
        console.log("result:")
        console.log(response.data.map)
        console.log("testdata.firstCheckRecords:")
        console.log(testdata.firstCheckRecords)
        // myData.pageParams = response.data.map.pageParams
      } else {
        ElMessageBox.alert("无首检信息！", '结果')
      }
    } else {
      ElMessageBox.alert(response.data.msg, '结果')
    }
  }).catch((error) => {
    ElMessageBox.alert("系统错误！", '结果')
  })
}
selectData()

//按条件获取数据
function selectData1() {
  console.log("Data:")
  console.log(Data)
  axios({
    method: 'post',
    url: '/api/firstCheckRecords/select1',
    data: Data.conditions
  }).then((response) => {
    if (response.data.success) {
      if (response.data.map.firstCheckRecords != null) {
        testdata.firstCheckRecords = response.data.map.firstCheckRecords
        console.log("result:")
        console.log(response.data.map)
        console.log("testdata.firstCheckRecords:")
        console.log(testdata.firstCheckRecords)
        // myData.pageParams = response.data.map.pageParams
      } else {
        ElMessageBox.alert("无首检信息！", '结果')
      }
    } else {
      ElMessageBox.alert(response.data.msg, '结果')
    }
  }).catch((error) => {
    ElMessageBox.alert("系统错误！", '结果')
  })
}
//表单序号自增
const indexMethod = (index) => {
  return index + 1
}

</script>

<template>
  <el-row style="background-color:white;margin:20px 10px 0 10px">
    <el-col :span="5" style="margin:10px 0 0 10px">
      <el-date-picker v-model="Data.conditions.startDate" type="date" placeholder="审批时间" />
    </el-col>
    <el-col :span="5" style="margin-top:10px">
      <el-date-picker v-model="Data.conditions.endDate" type="date" placeholder="审批时间" />
    </el-col>
    <el-col :span="11" style="margin-top:10px;">
      <el-input v-model="Data.conditions.orderNoOrProductionNo" placeholder="请输入订单编号或生产序号" />
    </el-col>
    <el-col :span="2" style="margin-top:10px">
      <el-button type="success" @click="selectData1">查询</el-button>
    </el-col>
  </el-row>
  <el-row style="background-color:white;margin:0 10px 0 10px">
    <el-col :span="24" style="margin-top:15px">
      <!--:data为测试数据，可对应数据库修改  stripe斑马纹效果 border带边框 -->
      <el-table :data="testdata.firstCheckRecords" stripe border style="width:100%">
        <!-- 定义列表属性 prop值可对于数据库字段名修改-->
        <el-table-column label="序号" align="center" type="index" :index="indexMethod" width="60"></el-table-column>
        <el-table-column label="订单编号" align="center" prop="orderNo" width="120" />
        <el-table-column label="生产序号" align="center" prop="productionNo" width="120" />
        <el-table-column label="产品型号" align="center" prop="productModel" width="220" />
        <el-table-column label="产品货号" align="center" prop="productNo" width="100" />
        <el-table-column label="计划日期" align="center" prop="planDate" width="110" />
        <el-table-column label="排产日期" align="center" prop="productionSchedulingDate" width="110" />
        <el-table-column label="订单数量" align="center" prop="orderQuantity" width="60" />
        <el-table-column label="首件数量" align="center" prop="firstQuantity" width="40" />
        <el-table-column label="首件状态" align="center" prop="firstState" width="90" />
        <el-table-column label="审批时间" align="center" prop="approveTime" width="110" />
        <el-table-column label="审批人员" align="center" prop="approver" />
      </el-table>
    </el-col>
  </el-row>
</template>

<style scoped>

</style>